package com.example.androidcomplete02.sqlite;

import android.app.ListActivity;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.widget.SimpleCursorAdapter;

public class ProductList extends ListActivity {
	@SuppressWarnings("deprecation")
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		ProductDBHelper mHelper = new ProductDBHelper(this);
		Cursor cursor;
		SQLiteDatabase db = mHelper.getWritableDatabase();
		cursor = db.rawQuery("SELECT * FROM product", null);
		startManagingCursor(cursor);
		SimpleCursorAdapter mAdapter = null;
		mAdapter = new SimpleCursorAdapter(this,
				android.R.layout.simple_list_item_2, cursor, new String[] {
						"name", "price" }, new int[] { android.R.id.text1,
						android.R.id.text2 });
		setListAdapter(mAdapter);
	}
}